/**
 * Created by Administrator on 2017/9/22.
 */
var isCurTableValid = function (ele) {
    var rs = $(ele).attr("isTableValid");
    return rs == 0;
};

var resetClickTableItemListener = function($) {
    $('.place-link').click(function(event) {
        if (!isCurTableValid(this)) {
            alert("对不起当前这桌已经有人!");
            return false;
        }
        //return false;
        //获取
        var numberTable  = $(this).attr("value");
        //选择桌号
        if (choiceTable($, numberTable)) {
            //跳转到点餐页面
            location.href="shop.html";
        }
    });
};



/*
 * 选择桌号
 */
var choiceTable = function($, numberTable) {
    //加到cookie
    //TODO: 为什么shopId经常没有 shopId
    var shopId = 0001;
    //var shopId=$.cookie('shopId');
    console.log("add>>>shopId>>"+shopId);
    if(shopId){
        //TODO：写入shopId
        $.cookie('shopId' ,shopId,{expires:1,path:'/'});//写cookie
        //写到cookies
        $.cookie('table'+shopId,numberTable,{expires:1,path:'/'});//写cookie
        return true;
    } else {
        alert("选择桌号失败：没有shopId");
        return false;
    }
};